﻿using DotNetClient;
using Frameworks;
using UnityEngine;

namespace Doudizhu
{
    public class DoudizhuManager : MonoBehaviour
    {
        public GameObject doudizhuMenu;
        public GameObject doudizhuRoom;
        public GameObject doudizhuGame;

        private void Start()
        {
            doudizhuMenu.SetActive(true);
            doudizhuRoom.SetActive(false);
            doudizhuGame.SetActive(false);

            EventProxy.AddEventListener(Routes.S2C_ROOM_ON_MATCH, onPushRoomMatch);
            EventProxy.AddEventListener(Routes.S2C_DOUDIZHU_ON_GAME_INIT, onPushDoudizhuGameInit);
        }

        private void OnDestroy()
        {
            EventProxy.RemoveEventListener(Routes.S2C_ROOM_ON_MATCH, onPushRoomMatch);
            EventProxy.RemoveEventListener(Routes.S2C_DOUDIZHU_ON_GAME_INIT, onPushDoudizhuGameInit);
        }

        private void onPushRoomMatch(EventData eventData)
        {
            doudizhuMenu.SetActive(false);
            doudizhuRoom.SetActive(true);
            doudizhuGame.SetActive(false);
        }

        private void onPushDoudizhuGameInit(EventData eventData)
        {
            doudizhuMenu.SetActive(false);
            doudizhuRoom.SetActive(false);
            doudizhuGame.SetActive(true);
        }

    }
}
